package com.tledu.ssm.core;

import com.tledu.ssm.core.exception.LoginException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

//通过这个对controller进行增强
@ControllerAdvice
public class ExceptionControllerAdvice {

    // 所有的controller都会加上这个操作
    @ExceptionHandler(value = {LoginException.class, NullPointerException.class})
    public String handleLoginError(LoginException e, Model model) {
        model.addAttribute("msg", e.getMessage());
        return "error";
    }


}
